<?php
namespace App\Http\Forms;

use App\Library\OSS;
use Kris\LaravelFormBuilder\Form;

class VideoForm extends Form
{
    public function buildForm()
    {
        $key = "video"."/".uniqid().random_int(10, 99);
        $this
            ->add('title', 'text', [
                'label' => "标题",
                'rules' => 'required|string',
            ])
            ->add('image', 'image', [
                'label' => "封面图片",
                'rules' => 'required|string',
                'type' => 'video_cover',
            ])
            ->add('video', 'video', [
                'label' => "上传视频",
                'rules' => 'nullable',
                'async' => true,
                'config' => OSS::instance('video')->getSign($key),
            ])
            ->add('submit', 'submit', [
                'attr' => ['class' => "form-control btn btn-success"],
                'label' => '保存',
            ]);
    }
}
